﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework06
{
    /*作业6:判断二维数组是否对称
编写一个程序，判断一个给定二维数组是否是对称的。对称数组是指其转置和自身相等，即数组的行和列互换后等于原数组。*/
    internal class Homework06
    {
        static void Main(string[] args)
        {
            //定义数组
            int[,] arr = {{ 2,1,1},
                          { 1,1,1},
                          { 2,1,1}};
            //定义标志
            int flag = 0;
            int[,] brr = new int[arr.GetLongLength(0),arr.GetLongLength(1)];

            for (int i = 0; i < arr.GetLongLength(0); i++)
            {
                for (int j = 0; j < arr.GetLongLength(1); j++)
                {
                    brr[i,j] = arr[j,i];
                    if (arr[i, j] != brr[i, j])
                    {
                        flag = 1;
                    }
                }
            }
            if (flag == 1) 
            {
                Console.WriteLine("该数组不是对称数组");
            }
            else
            {
                Console.WriteLine("该数组是对称数组");
            }
        }
    }
}
